#include "swoole.h"

int swSocket_create(){
	return socket(PF_INET,SOCK_STREAM,0);
}

int swSocket_bind(int sock, char *host, int *port){
	int ret;
	struct sockaddr_in addr_in4;

	int option = 1;
	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(int));

	bzero(&addr_in4,sizeof(addr_in4));
	inet_pton(AF_INET,host,&(addr_in4.sin_addr));
	addr_in4.sin_family = AF_INET;
	addr_in4.sin_port = htons(*port);

	ret = bind(sock,(struct sockaddr*)&addr_in4,sizeof(addr_in4));

	return ret;
}
